const path = require('path');

function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  baseUrl: './',
  // eslint-loader 在每次保存时执行校验的选项是默认开启的
  lintOnSave: false,
  // 不需要生产时的源映射，那么将此设置为false可以加速生产构建
  productionSourceMap: false,
  chainWebpack: (config) => {
    // 设置别名
    config.resolve.alias
      .set('@$', resolve('src'))
      .set('assets', resolve('src/assets'))
      .set('components', resolve('src/components'))
      .set('layout', resolve('src/layout'))
      .set('base', resolve('src/base'))
      .set('style', resolve('src/style'))
      .set('static', resolve('src/static'));
    config.module
      .rule('less')
      .oneOf('vue')
      .use('px2rem-loader')
      .loader('px2rem-loader')
      .before('postcss-loader')
      .options({ remUnit: 75, remPrecision: 8 })
      .end();
  },
  // 服务设置
  devServer: {
    open: true,
    port: 8088,
  },
};

